<template>
  <div class="main">
    <div class="banner">
      <el-carousel :interval="5000" arrow="always">
        <el-carousel-item
          v-for="item in adList.livestreaming_rotation_hart"
          :key="item.id"
        >
          <img
            @click="
              $router.push({
                path: '/highshop',
                query: {
                  id: item.storeId,
                },
              })
            "
            :src="item.imageUrl"
            alt=""
            style="height: 3.5rem; width: 14.2rem; cursor: pointer"
          />
        </el-carousel-item>
      </el-carousel>
    </div>
    <div class="recommend">
      <div class="title">
        <img
          src="../../assets/image/season/zhibo.png"
          alt=""
          style="margin-right: 0.12rem"
        />

        直播<span style="color: #ec6c15">热卖</span>
      </div>
      <div class="items">
        <div
          class="item"
          v-for="(item, index) in adList.livestreaming_hotSeller"
          @mouseover="(hovershow = true), (hoverindex = index)"
          @mouseleave="hovershow = false"
          :key="index"
          @click="
            $router.push({
              path: '/detail',
              query: {
                id: item.productId,
              },
            })
          "
        >
          <img
            class="spImg"
            :src="item.imageUrl"
            style="width: 100%; height: 1.88rem"
            alt=""
          />
          <div v-if="!hovershow || hoverindex != index" class="box1">
            <div
              style="
                width: 50%;
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
              "
            >
              {{ item.productName }}
            </div>
            <div
              style="
                font-size: 0.16rem;
                color: #e22a1f;
                margin-left: 0.1rem;
                width: 50%;
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
              "
            >
              ¥{{ item.productPrice }}
            </div>
          </div>
          <div v-if="hovershow && hoverindex == index" class="box2">
            <img
              src="../../assets/image/season/car.png"
              alt=""
              style="margin-right: 0.1rem"
            />
            加入购物车
          </div>
          <div class="hovertitle box3" v-if="hovershow && hoverindex == index">
            <div
              style="
                width: 50%;
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
              "
            >
              {{ item.productName }}
            </div>
            <span
              style=" width: 50%;
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;font-size: 0.16rem; color: #e22a1f; margin-left: 0.1rem"
              >¥{{ item.productPrice }}</span
            >
          </div>
        </div>
      </div>
    </div>
    <div class="quality">
      <div class="toptitle">
        <div class="leftbox">
          <div class="box4">全部<span class="span1"> 商品</span></div>
        </div>
        <div class="rightbox">
          <div
            :class="{ isactive: changeindex == index }"
            class="itembox"
            v-for="(item, index) in changelist"
            :key="index"
            @click="getType(index, item)"
          >
            {{ item.categoryName }}
            <img
              v-if="changeindex == index"
              class="bottomlogo"
              src="../../assets/image/season/sanjiao.png"
              alt=""
            />
          </div>
        </div>
      </div>
      <div class="screen">
        <div
          @click="getIconType(index)"
          class="leftbox"
          :class="{ isactive: screenindex == index }"
          v-for="(item, index) in screenlist"
          :key="index"
        >
          {{ item }}
        </div>
        <div class="leftbox">
          价格
          <div class="sanjiao">
            <div
              class="topsnjiao"
              @click="getIconType(3)"
              :class="{ isactiveB: screenindex == 3 }"
            ></div>
            <div
              class="bottomsanjiao"
              @click="getIconType(4)"
              :class="{ isactiveC: screenindex == 4 }"
            ></div>
          </div>
        </div>
        <div class="rightbox">
          <div class="rBox">
            <el-input
              v-model="input"
              placeholder="最小值"
              class="rBox"
            ></el-input>
          </div>
          ~
          <div class="rBox">
            <el-input
              v-model="input1"
              placeholder="最大值"
              class="rBox"
            ></el-input>
          </div>
          <div class="searchbutton" @click="query">查询</div>
        </div>
      </div>
      <div class="cardsbox">
        <div style="display: flex; justify-content: space-between">
          <div v-if="shopList.length" class="cards" style="marginleft: 0.15rem">
            <div v-for="(item, index) in shopList" :key="index">
              <Card
                :live="true"
                :item="item"
                :width="'2.2'"
                height="2.2"
                :bottom="'0.4'"
                :boxheight="'4.12'"
                style="margin-bottom: 0.18rem"
              ></Card>
            </div>
          </div>
        </div>
        <!-- <div style="display: flex; flex-wrap: wrap">
          <Card
            v-for="(item, index) in 10"
            :key="index"
            :width="'2.08'"
            height="2.08"
            :bottom="'0.4'"
            :boxheight="'3.62'"
            style="margin-bottom: 0.18rem"
          ></Card>
        </div> -->
      </div>
      <div class="bottombox">
        <el-pagination
          background
          style="font-size: 0.13rem"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="currentPage"
          :page-sizes="[20, 50, 100, 200]"
          :page-size="20"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
        >
        </el-pagination>
      </div>
    </div>
  </div>
</template>

<script>
import Card from "../commodity/components/Card.vue";
import { selectAllByParams, selectLiveProduct } from "@/api/seller/cangpushop";
import { getAllAd } from "../../api/home/index";
import { selectAllCondition, selectLiveProductCategory } from "@/api/commodity";
export default {
  components: {
    Card,
  },
  data() {
    return {
      input: "",
      input1: "",
      adList: {
        good_season: [],
      },
      hovershow: false,
      hoverindex: 0,
      changelist: [],
      changeindex: 0,
      screenlist: ["综合", "人气", "最新"],
      screenindex: 0,
      form: {
        pageNumber: 1,
        pageSize: 20,
        categoryId: "",
        market: "",
        priceRange: "",
        attributes: [],
        lookingFor: "",
        channelId: "",
        orderBy: "",
      },
      shopList: [],
      currentPage: 1,
      total: null,
    };
  },
  created() {
    this.getAllAd();
    this.selectAllByParams();
    this.selectAllCondition();
  },
  methods: {
    query() {
      if (this.input == "") {
        this.$message({
          message: "请输入最小值",
          type: "warning",
        });
        return false;
      }
      if (this.input1 == "") {
        this.$message({
          message: "请输入最大值",
          type: "warning",
        });
        return false;
      }
      this.form.priceRange = `${this.input}-${this.input1}`;
      this.selectAllByParams();
    },
    // 选择综合人气排序
    getIconType(index) {
      this.screenindex = index;
      this.form.orderBy = index + "";
      this.selectAllByParams();
    },
    // 根据分类查询
    getType(index, item) {
      this.changeindex = index;
      this.form.categoryId = item.categoryId;
      this.selectAllByParams();
    },
    // 获取所有类目
    selectAllCondition() {
      selectLiveProductCategory().then((data) => {
        this.changelist = data.data;
        // this.changelist.unshift({
        //   name: '全部',
        //   id: ''
        // })
      });
    },
    // 分页
    handleSizeChange(val) {
      this.form.pageSize = val;
      this.selectAllByParams();
    },
    handleCurrentChange(val) {
      this.form.pageNumber = val;
      this.selectAllByParams();
    },
    // 获取商品
    selectAllByParams() {
      selectLiveProduct(this.form).then((data) => {
        this.shopList = data.data.records;
        this.total = data.data.total;
      });
    },
    // 获取广告
    getAllAd() {
      getAllAd({
        adType: 4,
      }).then((data) => {
        this.adList = data.data;
      });
    },
  },
};
</script>

<style scoped lang="scss">
::v-deep .el-pagination.is-background .el-pager li:not(.disabled).active {
  background-color: #e22a1f !important;
}
::v-deep .el-pager li {
  width: 0.4rem !important;
  height: 0.4rem !important;
  line-height: 0.4rem !important;
  border-radius: 0.04rem !important;
}

::v-deep .el-pagination span {
  height: 0.4rem !important;
  line-height: 0.4rem !important;
}
::v-deep .el-pagination button {
  width: 0.4rem !important;
  height: 0.4rem !important;
  line-height: 0.4rem !important;
  border-radius: 0.04rem !important;
}
::v-deep .el-carousel__arrow--left {
  border-radius: 0 0.2rem 0.2rem 0 !important;
  left: 0;
}
::v-deep .el-carousel__arrow--right {
  border-radius: 0.2rem 0 0 0.2rem !important;
  right: 0;
}
::v-deep .el-dropdown {
  font-size: 0.12rem !important;
}
::v-deep .el-carousel__container {
  height: 3.2rem;
}
.el-carousel__item h3 {
  color: #475669;
  font-size: 18px;
  opacity: 0.75;
  line-height: 300px;
  margin: 0;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}
.main {
  //   padding-bottom: 0.42rem;
  width: 12rem;
  margin: 0 auto;
  // height: 100vh;
  margin-bottom: 0.41rem;
  //   background-color: #f5f7f9;
  overflow-y: hidden;
  .banner {
    height: 3.2rem;
    width: 100%;
    // background-color: black;
    margin-top: 0.21rem;
    margin-bottom: 0.2rem;
  }
  .recommend {
    // height: 6.35rem;
    width: 100%;
    // background-color: pink;
    .title {
      display: flex;
      align-items: center;
      height: 0.28rem;
      padding: 0.17rem 0 0.15rem 0.12rem;
      width: calc(100%-0.12rem);
      //   background-color: black;
      font-weight: 600;
      font-family: HYk1gj-regular;
      font-size: 0.24rem;
      background-color: #fff;
      border-bottom: 0.02rem solid #ec6c15;
      margin-bottom: 0.2rem;
    }
  }
  .items {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    .item:nth-child(6n + 6) {
      margin-right: 0;
    }
    .item {
      cursor: pointer;
      position: relative;
      display: flex;
      flex-direction: column;
      width: 1.88rem;
      height: 2.2rem;
      margin-right: 0.14rem;
      background-color: white;
      .hovertitle {
        position: absolute;
        background: rgba(255, 255, 255, 0.8);
        bottom: 0.35rem;
      }

      .box1 {
        display: flex;
        justify-content: space-around;
        height: 0.4rem;
        width: 100%;
        font-family: PingFang SC;
        font-size: 0.16rem;
        color: #333333;
        line-height: 0.3rem;
        text-align: left;
        display: flex;
      }
      .box2 {
        height: 0.4rem;
        width: 100%;
        text-align: center;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        font-family: OPPOSans;
        font-size: 0.16rem;
        font-weight: bold;
        color: white;
        line-height: 0.3rem;
        background-color: #ec6c15;
      }
      .box3 {
        height: 0.4rem;
        width: 100%;
        font-family: PingFang SC;
        font-size: 0.16rem;
        color: #333333;
        line-height: 0.4rem;
        display: flex;
        justify-content: space-around;
        color: #333333;
        text-align: left;
        background-color: rgba(255, 255, 255, 0.8);
      }
    }
    .item:nth-child(-n + 12):nth-child(n + 7) {
      margin-top: 0.12rem;
    }
  }
  .quality {
    margin-top: 0.2rem;
    width: 100%;
    // height: 100vh;
    background-color: #fff;

    .toptitle {
      width: calc(100% - 0.2rem);
      height: 0.4rem;
      //   background-color: pink;
      padding: 0.1rem 0 0.1rem 0.2rem;
      display: flex;
      //   justify-content: center;
      border-bottom: 0.04rem solid #ec6c15;
      .leftbox {
        .box4 {
          font-family: HYk1gj-regular;
          font-size: 0.24rem;
          color: #000000;
          font-weight: 600;
        }
        .span1 {
          font-family: HYk1gj-regular;
          font-size: 0.24rem;
          color: #ec6c15;
        }
        .box5 {
          width: 0.32rem;
          display: inline;
          height: 0.17rem;
          background: #a7adb8;
          font-family: HYk1gj-regular;
          text-align: center;
          font-size: 0.1rem;
          color: #666666;
        }
        .box6 {
          font-family: HYk1gj-regular;
          font-size: 0.12rem;
          color: #666666;
          font-weight: 600;
          margin-left: 0.04rem;
        }
        .bottom {
          display: flex;
          align-items: center;
          //   margin-top: 0.04rem;
        }
      }

      .rightbox {
        margin-left: 0.29rem;
        flex: 1;
        // background-color: black;
        border-left: 0.01rem solid #e8e8e8;
        display: flex;
        align-items: center;

        .itembox {
          cursor: pointer;
          min-width:0.8rem;
          height: 0.2rem;
          position: relative;
          //   background-color: black;
          text-align: center;
          font-family: PingFang SC;
          font-size: 0.16rem;
          border-right: 0.01rem solid #e8e8e8;
          padding: 0 0.1rem;
          .bottomlogo {
            position: absolute;
            bottom: -0.1rem;
            left: 34%;
          }
        }
        .isactive {
          color: #ec6c15;
          font-weight: 600;
        }
        .itembox:last-child {
          border-right: none;
        }
      }
    }
    .isactiveB {
      border-color: transparent transparent #ec6c15 !important;
      font-weight: 600;
    }
    .isactiveC {
      border-color: #ec6c15 transparent transparent transparent !important;
      font-weight: 600;
    }
    .screen {
      font-family: PingFang SC;
      font-size: 0.16rem;
      color: #666666;
      display: flex;
      align-items: center;
      width: 100%;
      height: 0.42rem;
      border: 0.01rem solid #e8e8e8;
      border-top: none;
      .rightbox {
        margin-left: 0.2rem;
        display: flex;
        align-items: center;
        .rBox {
          width: 0.8325rem;
          height: 0.23rem;
          // background: #ebebeb;
          font-family: PingFang SC;
          font-size: 0.12rem;
          line-height: 0.28rem;
          margin-right: 0.02rem;
        }
        /deep/ .el-input__inner {
          width: 0.8325rem;
          height: 0.23rem !important;
          background: #ebebeb;
          font-family: PingFang SC;
          font-size: 0.16rem;
          line-height: 0.28rem;
          margin-right: 0.02rem;
        }
        .searchbutton {
          width: 0.61rem;
          height: 0.28rem;
          background: #ec6c15;
          margin-left: 0.0711rem;
          font-family: PingFang SC;
          font-size: 0.16rem;
          color: #ffffff;
          text-align: center;
          line-height: 0.28rem;
          cursor: pointer;
        }
      }
      .leftbox {
        cursor: pointer;
        position: relative;
        height: 0.32rem;
        width: 1rem;
        text-align: center;
        line-height: 0.32rem;
        // background-color: yellow;
        border-right: 0.01rem solid #e8e8e8;
        .sanjiao {
          position: absolute;
          top: 0.01rem;
          right: 0.1rem;
          display: flex;
          flex-direction: column;
          align-items: center;
          .topsnjiao {
            cursor: pointer;
            width: 0;
            height: 0;
            border: 0.08rem solid;
            border-color: transparent transparent #d8d8d8;
          }
          .bottomsanjiao {
            cursor: pointer;
            width: 0;
            height: 0;
            border: 0.08rem solid;
            margin-top: 0.0167rem;
            border-color: #d8d8d8 transparent transparent transparent;
          }
        }
      }
      .isactive {
        color: #ec6c15;
        font-weight: 600;
      }
      .leftbox:last-child {
        border-right: none;
      }
    }
    .cardsbox {
      display: flex;
      align-items: center;
      background-color: #fff;
      padding: 0.16rem 0.14rem 0 0.16rem;
      .cards {
        // margin-left: 0.15rem;
        display: flex;
        flex-wrap: wrap;
        overflow: hidden;
      }
    }
    .bottombox {
      width: 100%;
      height: 0.7rem;
      margin: 0 auto;
      display: flex;
      justify-content: center;
      align-items: center;
      //   margin-bottom: 0.42rem;
      background-color: white;
    }
  }
}
</style>
<style scoped lang="scss">
@media screen and (max-width: 1300px) {
  .main {
    //   padding-bottom: 0.42rem;
    width: 90%;
    margin: 0 auto;
    // height: 100vh;
    margin-bottom: 0.41rem;
    //   background-color: #f5f7f9;
    overflow-y: hidden;
    .banner {
      height: 4.2rem;
      width: 100%;
      // background-color: black;
      margin-top: 0.21rem;
      margin-bottom: 0.2rem;
      /deep/.el-carousel__container {
        height: 4.2rem !important;
      }
      img {
        width: 100% !important;
        height: 4.2rem !important;
      }
    }
    .recommend {
      height: 7.48rem;
      width: 100%;
      // background-color: pink;
      .title {
        display: flex;
        align-items: center;
        height: 0.28rem;
        padding: 0.17rem 0 0.15rem 0.12rem;
        width: calc(100%-0.12rem);
        //   background-color: black;
        font-weight: 600;
        font-family: HYk1gj-regular;
        font-size: 0.24rem;
        background-color: #fff;
        border-bottom: 0.02rem solid #ec6c15;
        margin-bottom: 0.2rem;
      }
    }
    .items {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      justify-content: space-between;
      .item {
        cursor: pointer;
        position: relative;
        display: flex;
        flex-direction: column;
        width: 2.33rem;
        height: 2.75rem;
        background-color: white;
        .spImg {
          height: 2.75rem !important;
        }

        .hovertitle {
          position: absolute;
          background: rgba(255, 255, 255, 0.8);
          bottom: 0.38rem;
        }
        .box1 {
          display: flex;
          justify-content: space-around;
          height: 0.4rem;
          width: 100%;
          font-family: PingFang SC;
          font-size: 0.16rem;
          color: #333333;
          line-height: 0.3rem;
          text-align: left;
        }
        .box2 {
          height: 0.4rem;
          width: 100%;
          text-align: center;
          display: flex;
          align-items: center;
          justify-content: center;
          cursor: pointer;
          font-family: OPPOSans;
          font-size: 16px;
          font-weight: bold;
          color: white;
          line-height: 0.3rem;
          background-color: #ec6c15;
        }
        .box3 {
          height: 0.4rem;
          width: 100%;
          font-family: PingFang SC;
          font-size: 0.16rem;
          color: #333333;
          line-height: 0.4rem;
          display: flex;
          justify-content: space-around;
          color: #333333;
          text-align: left;
          background-color: rgba(255, 255, 255, 0.8);
        }
      }
      .item:nth-child(-n + 12):nth-child(n + 7) {
        margin-top: 0.12rem;
      }
    }
    .quality {
      margin-top: -0.2rem;
      width: 100%;
      // height: 100vh;
      background-color: #fff;
      overflow: hidden;

      .toptitle {
        width: calc(100% - 0.2rem);
        height: 0.4rem;
        //   background-color: pink;
        padding: 0.1rem 0 0.1rem 0.2rem;
        display: flex;
        //   justify-content: center;
        border-bottom: 0.04rem solid #ec6c15;
        .leftbox {
          .box4 {
            font-family: HYk1gj-regular;
            font-size: 0.24rem;
            color: #000000;
            font-weight: 600;
          }
          .span1 {
            font-family: HYk1gj-regular;
            font-size: 0.24rem;
            color: #ec6c15;
          }
          .box5 {
            width: 0.32rem;
            display: inline;
            height: 0.17rem;
            background: #a7adb8;
            font-family: HYk1gj-regular;
            text-align: center;
            font-size: 0.1rem;
            color: #666666;
          }
          .box6 {
            font-family: HYk1gj-regular;
            font-size: 0.12rem;
            color: #666666;
            font-weight: 600;
            margin-left: 0.04rem;
          }
          .bottom {
            display: flex;
            align-items: center;
            //   margin-top: 0.04rem;
          }
        }

        .rightbox {
          margin-left: 0.29rem;
          flex: 1;
          // background-color: black;
          border-left: 0.01rem solid #e8e8e8;
          display: flex;
          align-items: center;

          .itembox {
            cursor: pointer;
            width: 1.26rem;
            height: 0.2rem;
            position: relative;
            //   background-color: black;
            text-align: center;
            font-family: PingFang SC;
            font-size: 0.14rem;
            border-right: 0.01rem solid #e8e8e8;
            .bottomlogo {
              position: absolute;
              bottom: -0.1rem;
              left: 0.32rem;
            }
          }
          .isactive {
            color: #ec6c15;
            font-weight: 600;
          }
          .itembox:last-child {
            border-right: none;
          }
        }
      }
      .isactiveB {
        border-color: transparent transparent #ec6c15 !important;
        font-weight: 600;
      }
      .isactiveC {
        border-color: #ec6c15 transparent transparent transparent !important;
        font-weight: 600;
      }
      .screen {
        font-family: PingFang SC;
        font-size: 0.12rem;
        color: #666666;
        display: flex;
        align-items: center;
        width: 100%;
        height: 0.42rem;
        border: 0.01rem solid #e8e8e8;
        border-top: none;
        .rightbox {
          margin-left: 0.2rem;
          display: flex;
          align-items: center;
          .rBox {
            width: 0.8325rem;
            height: 0.23rem;
            // background: #ebebeb;
            font-family: PingFang SC;
            font-size: 0.12rem;
            line-height: 0.28rem;
            margin-right: 0.02rem;
          }
          /deep/ .el-input__inner {
            width: 0.8325rem;
            height: 0.23rem !important;
            background: #ebebeb;
            font-family: PingFang SC;
            font-size: 0.12rem;
            line-height: 0.28rem;
            margin-right: 0.02rem;
          }
          .searchbutton {
            width: 0.61rem;
            height: 0.28rem;
            background: #ec6c15;
            margin-left: 0.0711rem;
            font-family: PingFang SC;
            font-size: 0.12rem;
            color: #ffffff;
            text-align: center;
            line-height: 0.28rem;
            cursor: pointer;
          }
        }
        .leftbox {
          cursor: pointer;
          position: relative;
          height: 0.32rem;
          width: 1rem;
          text-align: center;
          line-height: 0.32rem;
          // background-color: yellow;
          border-right: 0.01rem solid #e8e8e8;
          .sanjiao {
            position: absolute;
            top: 0.01rem;
            right: 0.1rem;
            display: flex;
            flex-direction: column;
            align-items: center;
            .topsnjiao {
              cursor: pointer;
              width: 0;
              height: 0;
              border: 0.08rem solid;
              border-color: transparent transparent #d8d8d8;
            }
            .bottomsanjiao {
              cursor: pointer;
              width: 0;
              height: 0;
              border: 0.08rem solid;
              margin-top: 0.0167rem;
              border-color: #d8d8d8 transparent transparent transparent;
            }
          }
        }
        .isactive {
          color: #ec6c15;
          font-weight: 600;
        }
        .leftbox:last-child {
          border-right: none;
        }
      }
      .cardsbox {
        display: flex;
        align-items: center;
        background-color: #fff;
        padding: 0.16rem 0.14rem 0 0.16rem;
        .leftImg {
          width: 3.3rem !important;
          height: 9rem !important;
        }
        .cards {
          margin-left: 0.06rem;
          display: flex;
          flex-wrap: wrap;
          overflow: hidden;
        }
      }
      .bottombox {
        width: 100%;
        height: 0.7rem;
        margin: 0 auto;
        display: flex;
        justify-content: center;
        align-items: center;
        //   margin-bottom: 0.42rem;
        background-color: white;
      }
    }
  }
}
</style>
